#
#Political Shocks and Asset Prices
#
# Replication file
# 
#Code to generate p-values using empirical distribution
#
# Note that because of the simulation strategy, the obtained p-values may not be exactly like the ones reported in the paper. But, they should be within one or two decimals from them.
# 
# Version July 28 2021 
#
#
rm(list=ls(all=TRUE))
#
library(foreign)
library(lmtest)
library(sandwich)
#
#
# Set Directory Path - You will need to change accordingly
#
setwd("/Users/ssaiegh/Files/Mac/UCSD/Carnahan/Shocks/Replication Files")
#
# Read Data File -- This file contains the volatility ratios for all non-event dates.
#
data <-read.dta("one_day_loop.dta")
attach(data,warn.conflicts=FALSE)
#
# **** TABLE 3 ****
#
# **** PANEL A **** 
#
# Set the Number of Events to be Seeded 
#
# **** ALL EVENTS ****
#
n <- 111
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
# The final step is to compare the simulated t-values with those of the event-days reported in Tables 2 and 3.
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.423)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 4.606)/100)/100
#
#
# **** CHANGE IN ECONOMIC STEWARDSHIP **** 
#
n <- 53
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >1.005)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 3.689)/100)/100
#
# **** CHANGE IN ECONOMIC STEWARDSHIP (SAME GOVERNMENT)**** 
#
n <- 41
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >1.436)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 3.087)/100)/100
#
# **** CHANGE IN ADMINISTRATION **** 
#
n <- 16
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-3.754)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.502)/100)/100
#
# **** IRREGULAR CHANGE IN ADMINISTRATION **** 
#
n <- 8
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-1.298)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.106)/100)/100
#
# **** PLANNED SUCCESSION **** 
#
n <- 8
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-10.863)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 1.382)/100)/100
#
# **** NATIONAL ELECTION **** 
#
n <- 28
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.265)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.495)/100)/100
#
# **** TERRORIST ACT **** 
#
n <- 24
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-0.881)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 0.916)/100)/100
#
#
# **** PANEL B **** 
#
# Set the Number of Events to be Seeded 
#
# **** ALL EVENTS ****
#
n <- 66
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
# The final step is to compare the simulated t-values with those of the event-days reported in Tables 2 and 3.
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.179)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 3.495)/100)/100
#
#
# **** CHANGE IN ECONOMIC STEWARDSHIP **** 
#
n <- 25
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.763)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.260)/100)/100
#
# **** CHANGE IN ECONOMIC STEWARDSHIP (SAME GOVERNMENT)**** 
#
n <- 15
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >1.150)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 1.167)/100)/100
#
# **** CHANGE IN ADMINISTRATION **** 
#
n <- 12
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-2.679)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.344)/100)/100
#
# **** IRREGULAR CHANGE IN ADMINISTRATION **** 
#
n <- 5
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-0.561)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.154)/100)/100
#
# **** PLANNED SUCCESSION **** 
#
n <- 7
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-10.396)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 1.234)/100)/100
#
# **** NATIONAL ELECTION **** 
#
n <- 28
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.265)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.495)/100)/100
#
# **** TERRORIST ACT **** 
#
n <- 10
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-3.115)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 0.385)/100)/100
#
#
# **** PANEL C **** 
#
# Set the Number of Events to be Seeded 
#
# **** ALL EVENTS ****
#
n <- 34
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
# The final step is to compare the simulated t-values with those of the event-days reported in Tables 2 and 3.
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.281)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.084)/100)/100
#
#
# **** CHANGE IN ECONOMIC STEWARDSHIP **** 
#
n <- 22
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >1.018)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 1.783)/100)/100
#
# **** CHANGE IN ECONOMIC STEWARDSHIP (SAME GOVERNMENT)**** 
#
n <- 15
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >1.150)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 1.167)/100)/100
#
# **** CHANGE IN ADMINISTRATION **** 
#
n <- 8
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-1.485)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 1.907)/100)/100
#
# **** IRREGULAR CHANGE IN ADMINISTRATION **** 
#
n <- 5
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-0.561)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.154)/100)/100
#
#
# **** TERRORIST ACT **** 
#
n <- 10
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio_dol, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-3.115)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 0.385)/100)/100
#
# **** PANEL D **** 
#
# NOTE: YOU NEED TO LOAD A DIFFERENT DATASET
#
# Read Data File -- This file contains the volatility ratios for intraday data in all non-event dates.
#
data <-read.dta("intraday_loop.dta")
attach(data,warn.conflicts=FALSE)
#
# Set the Number of Events to be Seeded 
#
# **** ALL EVENTS ****
#
n <- 50
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
# The final step is to compare the simulated t-values with those of the event-days reported in Tables 2 and 3.
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.029)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 3.091)/100)/100
#
#
# **** CHANGE IN ECONOMIC STEWARDSHIP **** 
#
n <- 27
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >0.499)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.481)/100)/100
#
# **** CHANGE IN ECONOMIC STEWARDSHIP (SAME GOVERNMENT)**** 
#
n <- 20
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-0.316)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.302)/100)/100
#
# **** CHANGE IN ADMINISTRATION **** 
#
n <- 9
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >1.751)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 0.025)/100)/100
#
# **** PLANNED SUCCESSION **** 
#
n <- 7
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >1.364)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > -0.305)/100)/100
#
# **** NATIONAL ELECTION **** 
#
n <- 20
#
#
# The following Loop generates the simulated t-values
#
bstrap <- c()
for (i in 1:10000){
newsample <- sample(ratio, n, replace=T)
bstrap <- c(bstrap, mean(newsample)/(sd(newsample)/sqrt(n)))
}
# 
#
# Pre-Event Volatility P-value
#
(sum(bstrap >-0.577)/100)/100
#
#Post-Event Volatility P-Value
#
(sum(bstrap > 2.616)/100)/100
#
